/*
 **  VIPABC Wechat API config
 **  2016-10-27
 **  License: vipabc.com
 */
var url_wx_config = '';
if (window.location.host.indexOf("stage") > -1) {
    url_wx_config = '//stage.vipabc.com/aspx/MGMWechatPlatform/Share/GetWechatJsApiTicket';
} else {
    url_wx_config = '//www.vipabc.com/aspx/MGMWechatPlatform/Share/GetWechatJsApiTicket';
}

function InitWXConfig() {
    $.ajax({
        type: 'GET',
        url: url_wx_config + '?url=' + escape(window.location.href),
        dataType: "json",
        async: false,
        success: function (data) {

            if ((typeof wx) != "undefined") {

                wx.config({
                    debug: false,
                    appId: data.appId,
                    timestamp: data.timestamp,
                    nonceStr: data.nonceStr,
                    signature: data.signature,
                    jsApiList: [
						'checkJsApi',
						'onMenuShareTimeline',
						'onMenuShareAppMessage',
						'onMenuShareQQ',
						'onMenuShareWeibo',
						'hideMenuItems',
						'showMenuItems',
						'hideAllNonBaseMenuItem',
						'showAllNonBaseMenuItem',
						'translateVoice',
						'startRecord',
						'stopRecord',
						'onRecordEnd',
						'playVoice',
						'pauseVoice',
						'stopVoice',
						'uploadVoice',
						'downloadVoice',
						'chooseImage',
						'previewImage',
						'uploadImage',
						'downloadImage',
						'getNetworkType',
						'openLocation',
						'getLocation',
						'hideOptionMenu',
						'showOptionMenu',
						'closeWindow',
						'scanQRCode',
						'chooseWXPay',
						'openProductSpecificView',
						'addCard',
						'chooseCard',
						'openCard'
					  ]
                });

                wx.ready(function () {
                    wxAPIConfig();
                });

            }

        },
        error: function (error) {
            //alert(error.responseText);
        }
    });
}

InitWXConfig();